﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Bll.AIR;

namespace EZCRS.HCMS.Web.manage.ta
{
    public partial class channel_new : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    int iID = 0;
                    
                    int.TryParse(Request.QueryString["id"], out iID);

                    LoadData(iID);
                }
            }
        }

        private void LoadData(int ID)
        {
            TAChannel bll = new TAChannel();

            Channel cl = bll.GetItem(ID);

            if (cl != null)
            {
                txtID.Text = cl.Code;
                txtName.Text = cl.Name;

                txtRate1.Text = cl.Remark;

            }
        }

        protected void btnsave_Click(object sender, EventArgs e)
        {
            TAChannel bll = new TAChannel();

            Channel cl = new Channel();

            if (Request.QueryString["id"] != null)
            {
                int iID = 0;

                int.TryParse(Request.QueryString["id"], out iID);

                cl.ID = iID;
            }

            cl.Name = txtName.Text;
            cl.Remark = txtRate1.Text;
            cl.Code = txtID.Text;

            bll.Save(cl);

            Response.Write("<script>window.parent.Close()</script>");
        }
    }
}
